<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
      xmlns:p="http://primefaces.org/ui"
      xmlns:h="http://xmlns.jcp.org/jsf/html"
      xmlns:f="http://xmlns.jcp.org/jsf/core">

    <body>

        <ui:composition template="./../pageTemplate.xhtml">

            <ui:define name="content">
                <h3>Archivo de Vulnerabilidades</h3>
                <p:separator />
                <div class="contentStyle">
                    <h:form id="tableform">
                        <p:growl autoUpdate="true" showDetail="true" showSummary="true" />
                        <p:contextMenu for="vulnsTable">
                            <p:menuitem value="#{jsfmsgs.perYear_context_detalle}" 
                                        update=":tableform:vulnDetail" icon="ui-icon-search" oncomplete="PF('vulnDialog').show()" />
                        </p:contextMenu>
                        <p:dataTable id="vulnsTable" var="vuln" value="#{vulnerabilityBean.vulnArchive}" 
                                     rowKey="#{vuln.name}"
                                     selection="#{vulnerabilityBean.selectedVuln}"
                                     selectionMode="single" rows="20" paginator="true"
                                     paginatorTemplate="#{jsfmsgs.table_paginator_template}"
                                     emptyMessage="#{jsfmsgs.perYear_table_empty_query}"
                                     filteredValue="#{vulnerabilityBean.filteredVulns}"
                                     rowsPerPageTemplate="20, 25, 30" sortMode="multiple">
                            <p:column headerText="Nombre" sortBy="#{vuln.name}" filterBy="#{vuln.name}" filterMatchMode="contains">
                                <h:outputText value="#{vuln.name}" />
                            </p:column>
                            <p:column headerText="Criticidad" sortBy="#{vuln.severity}" >
                                <h:outputText value="#{vuln.severity}" />
                            </p:column>
                            <p:column headerText="Calificación/CVSS" sortBy="#{vuln.CVSS.score}" filterBy="#{vuln.CVSS.score}" filterMatchMode="contains">
                                <h:outputText value="#{vuln.CVSS.score}" />
                            </p:column>
                            <p:column headerText="Fecha de Publicación" sortBy="#{vuln.published}">
                                <h:outputText value="#{vuln.published}">
                                    <f:convertDateTime pattern="dd-MM-yyyy" />
                                </h:outputText>
                            </p:column>
                        </p:dataTable>
                        <p:dialog header="#{jsfmsgs.perYear_vuln_dialog_header}" position="center" widgetVar="vulnDialog" modal="true" 
                                  showEffect="fade" hideEffect="fade" resizable="false" styleClass="customDialog">
                            <p:scrollPanel mode="native" style="height: 600px">
                                <p:outputPanel id="vulnDetail" style="max-width: 1000px">
                                    <p:panelGrid columns="2" rendered="#{not empty vulnerabilityBean.selectedVuln}">
                                        <f:facet name="header">
                                            <p:row>
                                                <p:column colspan="2">
                                                    <h:outputText value="#{vulnerabilityBean.selectedVuln.name}" />
                                                </p:column>
                                            </p:row>
                                        </f:facet>
                                        <h:outputText value="Fecha de Publicación: " />
                                        <h:outputText value="#{vulnerabilityBean.selectedVuln.published}">
                                            <f:convertDateTime pattern="dd-MM-yyyy" />
                                        </h:outputText>
                                        <h:outputText value="Fecha de Modificación: " />
                                        <h:outputText value="#{vulnerabilityBean.selectedVuln.modified}">
                                            <f:convertDateTime pattern="dd-MM-yyyy" />
                                        </h:outputText>
                                        <h:outputText value="Criticidad/Criticalidad: " />
                                        <h:outputText value="#{vulnerabilityBean.selectedVuln.severity}" />
                                        <h:outputText value="Calificación/CVSS: " />
                                        <h:outputText value="#{vulnerabilityBean.selectedVuln.CVSS.score}" />
                                        <h:outputText value="Vector CVSS: " />
                                        <h:outputText value="#{vulnerabilityBean.selectedVuln.CVSS.vector}" />
                                        <h:outputText value="Descripción: " />
                                        <p>
                                            #{vulnerabilityBean.selectedVuln.description}
                                        </p>
                                        <h:outputText value="Referencias:" />
                                        <ui:repeat value="#{vulnerabilityBean.selectedVuln.references}" var="ref">
                                            <h:outputText value="#{ref.source}" /><br />
                                            <h:outputText value="#{ref.url}" style="margin-left:5em" /><br />
                                        </ui:repeat>
                                        <h:outputText value="Software Afectado: " />
                                        <ui:repeat value="#{vulnerabilityBean.selectedVuln.vuln_soft}" var="swa">
                                            <h:outputText value="#{swa.vendor.toUpperCase()}" /><br />
                                            <h:outputText style="margin-left: 5em" value="Producto: " />
                                            <h:outputText value="#{swa.name}" /><br />
                                            <h:outputText style="margin-left: 5em" value="Versión(es): " /><br />
                                            <h:outputText value="#{swa.version}" style="margin-left: 7em; font-size: 80%" /><br />
                                        </ui:repeat>
                                    </p:panelGrid>
                                </p:outputPanel>
                            </p:scrollPanel>
                        </p:dialog>
                        <p:blockUI block="vulnsTable" trigger="vulnsTable" >
                            #{jsfmsgs.loadingMessage} <br />
                            <p:graphicImage library="images" name="loading.gif" style="width: 32px; height: 32px" />
                        </p:blockUI>
                    </h:form>
                </div>
            </ui:define>

        </ui:composition>

    </body>
</html>
                                        
                                        <!--
                                        <h:outputText value="Descargar" />
                                        <p:commandButton ajax="false" icon="ui-icon-arrowthickstop-1-s" >
                                            <p:fileDownload value="# {vulnerabilityBean.file}" />
                                        </p:commandButton>
                                        -->